/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package epam_java.telephone.users;

import epam_java.telephone.bill.Bill;
import epam_java.telephone.services.AbstractService;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import org.omg.CORBA.MARSHAL;

/**
 *
 * @author Meluk
 */
public class SubscriberUser extends AbstractUser{
   private ArrayList<Bill> bills;
    public SubscriberUser(int userId, String userName, String login, String pass) {
        super(userId, userName, login, pass, Acces.SUBSCRIBER);
        bills= new ArrayList<Bill>();
    }
    /**
     * add new service to subscriber list
     * @param serviceNumber
     */
 public   void choiceService(int serviceNumber){

    }
    /**
     * pay a Bill
     */
  public  void payBill(long billNumber){

    }
  public  void doService(){

    }
  public ArrayList<Bill> getBills(){
      return bills;
  }
  public void addBill(Bill bill){
     bills.add(bill);
  }
  public double getSummaryPrice(){
      double sum=0;
        for(Bill bill:bills){
            sum+=bill.getService().getPriceUnit()*bill.getCountServices();
        }
        return sum;
  }

  public Bill doService(AbstractService service,PrintWriter streamout){
      int serviceduration=(int)Math.round(Math.random()*100);
      streamout.println("<br>Вы воспользовались услугой: "+service.getName());
      streamout.println("<br>Описание услуги: "+service.getDescription());
      streamout.println(" Длительность услуги: "+serviceduration);
      return new Bill(service,false,serviceduration);
  }
}
